﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using snat.proxy.items;

namespace snat.proxy.sqlapi {
    public static class ConnectionQuery {

        public static ListProxy<DBConnection> Init() {
            return Query.SQLQuery<snat.proxy.items.DBConnection>(@"SELECT * FROM Connected WHERE Initial = 1 ",
@"SELECT * FROM Entity NATURAL JOIN (SELECT FromEntityID as EntityID FROM (select * from Connected WHERE Initial=1 LIMIT ?position,?bufferSize) as du UNION SELECT ToEntityID as EntityID FROM (select * from Connected WHERE Initial=1 LIMIT ?position,?bufferSize) as da ) as d1;");
        }


        public static ListProxy<DBConnection> All() {
            return Query.SQLQuery<snat.proxy.items.DBConnection>(@"SELECT * FROM Connected",
@"SELECT * FROM Entity NATURAL JOIN (SELECT FromEntityID as EntityID FROM (select * from Connected LIMIT ?position,?bufferSize) as du UNION SELECT ToEntityID as EntityID FROM (select * from Connected LIMIT ?position,?bufferSize) as da ) as d1;");
        }

    }
}
